package enums

const (
	ModelUnknown = iota
	ModelIet     // 雷森型号 1-5
	_
	_
	_
	_
	ModelDTAMD29 // 慧尔视型号 6-10
	_
	_
	_
	_
	ModelTongshiPlatform // 同视平台
	ModelTongshiRadar    // 同视雷达
)

const (
	BrandUnknown  = iota
	BrandLeisen   // 雷森
	BrandHuiershi // 慧尔视
	BrandTongshi  // 同视
)

const (
	StatusUnknown = iota
	StatusOnline
	StatusOffline
	StatusError
)

const (
	RadarSubDeviceTypeGeneral    = 99 // 【雷达】通用
	RadarSubDeviceTypeThirdParty = 1  // 【雷达】第三方
)

type EnumsInfo struct {
	Name       string `json:"name"`
	Value      int    `json:"value"`
	Permission int    `json:"permission,omitempty"`
}

type UserDataInfo struct {
	Key         string           `json:"key" validate:"required"`
	DisplayName string           `json:"display_name" validate:"required"`
	Type        string           `json:"type" validate:"oneof=string number bool choice multi"`
	Selects     []UserDataSelect `json:"selects" validate:"required_if=Type choice,required_if=Type multi,dive"`
}

type UserDataSelect struct {
	Key         string `json:"key" validate:"required"`
	DisplayName string `json:"display_name" validate:"required"`
}

var BrandMap map[int]EnumsInfo              // read only
var ModelMap map[int]map[int]EnumsInfo      // read only
var StatusMap map[int]EnumsInfo             // read only
var RadarSubDeviceTypeMap map[int]EnumsInfo // read only
var AllEnumsMap map[string]interface{}      // read only, all

func init() {
	BrandMap = map[int]EnumsInfo{
		BrandLeisen:   {Name: "雷森", Value: BrandLeisen},
		BrandHuiershi: {Name: "慧尔视", Value: BrandHuiershi},
		BrandTongshi:  {Name: "同视", Value: BrandTongshi},
	}
	ModelMap = map[int]map[int]EnumsInfo{
		BrandLeisen: {
			ModelIet: {Name: "IET", Value: ModelIet},
		},
		BrandHuiershi: {
			ModelDTAMD29: {Name: "DTAM D29", Value: ModelDTAMD29},
		},
		BrandTongshi: {
			ModelTongshiPlatform: {Name: "同视平台", Value: ModelTongshiPlatform},
			ModelTongshiRadar:    {Name: "同视雷达", Value: ModelTongshiRadar},
		},
	}
	StatusMap = map[int]EnumsInfo{
		StatusOnline:  {Name: "在线", Value: StatusOnline},
		StatusOffline: {Name: "离线", Value: StatusOffline},
		StatusError:   {Name: "故障", Value: StatusError},
	}
	StatusMap = map[int]EnumsInfo{
		StatusOnline:  {Name: "在线", Value: StatusOnline},
		StatusOffline: {Name: "离线", Value: StatusOffline},
		StatusError:   {Name: "故障", Value: StatusError},
	}
	RadarSubDeviceTypeMap = map[int]EnumsInfo{
		RadarSubDeviceTypeGeneral: {
			Name:  "【雷达】通用",
			Value: RadarSubDeviceTypeGeneral,
		},
		RadarSubDeviceTypeThirdParty: {
			Name:  "【雷达】第三方",
			Value: RadarSubDeviceTypeThirdParty,
		},
	}
	AllEnumsMap = map[string]interface{}{
		"brand":  BrandMap,
		"model":  ModelMap,
		"status": StatusMap,
		"type":   RadarSubDeviceTypeMap,
	}
}
